package com.hzhr.iot.core.exception;

import com.hzhr.iot.core.constant.ResponseCode;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;

import java.nio.charset.Charset;

public class IotHttpClientErrorException extends HttpClientErrorException {
    private Integer code;
    private String des;

    public IotHttpClientErrorException(HttpStatus statusCode) {
        super(statusCode);
    }

    public IotHttpClientErrorException(HttpStatus statusCode, ResponseCode responseCode) {
        super(statusCode);
        this.code = responseCode.getCode();
        this.des = responseCode.getDes();
    }

    public IotHttpClientErrorException(HttpStatus statusCode, String statusText) {
        super(statusCode, statusText);
    }

    public IotHttpClientErrorException(HttpStatus statusCode, String statusText, byte[] responseBody, Charset responseCharset) {
        super(statusCode, statusText, responseBody, responseCharset);
    }

    public IotHttpClientErrorException(HttpStatus statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody, Charset responseCharset) {
        super(statusCode, statusText, responseHeaders, responseBody, responseCharset);
    }

    public Integer getCode() {
        return code;
    }

    public String getDes() {
        return des;
    }
}
